#include <stdio.h>
#include <stdlib.h>
int a[12]={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y, d, m, i, x;
int day_number(int d, int m, int y)
{
        if((y<=0)||(d<=0)||(m<=0)||(m>12)||(d>a[m-1])||((m==2)&&(d==29)&&((y%4!=0)||((y%100==0)&&(y%400!=0)))))
                {
                        return -1;
                }

  
          if(((y%4!=0)||((y%100==0)&&(y%400!=0)))&&(m>2))
                {
                         x=-1;
                }
        else
                {
                        x=0;
                }
        for(i=0; i<m-1; i++)
        {
                x=x+a[i];
        }
        return x+d;
}
void main()
{int y, d, m;
        printf("vvedite dutu, mesyac i god:\n");
        x=scanf("%d %d %d", &d, &m, &y);
      
        if(day_number(d,m,y)==-1)
                {
                        printf("nevernii vvod!\n");
                        system("PAUSE");
                }
        else
                {
                        printf("nomer dnya v godu: %d\n", day_number(d,m,y));                       
                }
		 system("PAUSE");
}